package com.huang.controller;

import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.*;

@Controller
public class RestFulController {
    @RequestMapping(value = "/add/{a}/{b}", method = RequestMethod.POST)
//    @PostMapping()
//    @GetMapping()  代替method = RequestMethod.POST方便好用
    //在Spring MVC中可以使用 @PathVariable 注解，让方法参数的值对应绑定到一个URI模板变量上。
    public String test(@PathVariable int a, @PathVariable int b, Model model) {
        int x = a + b;
        model.addAttribute("msg", "结果：" + x);
        return "hello";
    }
}
